#region

using System;
using System.ComponentModel.DataAnnotations;
using ThuySan.Bussiness;

#endregion

namespace ThuySan.Models
{
    [Serializable]
    public partial class ImageModel
    {
        #region Constructor

        public ImageModel()
        {
        }

        public ImageModel(Image value)
        {
            Id = value.Id;
            ProductId = value.ProductId;
            Description = value.Description;
            ImageName = value.ImageName;
            Priority = value.Priority;
            IsBanner = value.IsBanner ?? false;
        }

        #endregion

        #region Fields

        private String _Description;

        private Int32 _Id;

        private String _ImageName;

        private Boolean _IsBanner;

        private Int32? _Priority;

        private Int32? _ProductId;

        #endregion

        #region Properties

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public Int32 Id
        {
            get { return _Id; }
            set { _Id = value; }
        }

        //[NotChanged]
        [Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public Int32? ProductId
        {
            get { return _ProductId; }
            set { _ProductId = value; }
        }

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(1000, ErrorMessage = "Value must be under 1000 characters")]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public String Description
        {
            get { return _Description; }
            set { _Description = value; }
        }

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(300, ErrorMessage = "Value must be under 300 characters")]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public String ImageName
        {
            get { return _ImageName; }
            set { _ImageName = value; }
        }

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public Int32? Priority
        {
            get { return _Priority; }
            set { _Priority = value; }
        }

        //[NotChanged]
        //[Required(ErrorMessage = "Value is required")]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Email address is not valid")]
        public Boolean IsBanner
        {
            get { return _IsBanner; }
            set { _IsBanner = value; }
        }

        #endregion

        #region Operators

        public void Update(Image value)
        {
            //value.Id = Id;
            value.ProductId = ProductId;
            value.Description = Description;
            //value.ImageName = ImageName;
            value.Priority = Priority;
            value.IsBanner = IsBanner;
        }

        public static implicit operator ImageModel(Image obj)
        {
            return new ImageModel(obj);
        }

        public static implicit operator Image(ImageModel obj)
        {
            Image value = new Image();
            obj.Update(value);
            return value;
        }

        #endregion
    }
}
